/*     */ package com.newcrm.webapi.sub;
/*     */ 
/*     */ import com.newcrm.bean.CompanyInfo;
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.CustomerFieldManager;
/*     */ import com.newcrm.db.UserEmailManager;
/*     */ import com.newcrm.db.UserManager;
/*     */ import com.newcrm.db.UserVOIPManager;
/*     */ import com.newcrm.exception.DBException;
/*     */ import com.newcrm.exception.NotFoundException;
/*     */ import com.newcrm.webapi.AbstractAction;
/*     */ import com.newcrm.webapi.AbstractHttpServlet;
/*     */ import java.io.IOException;
/*     */ import java.sql.SQLException;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.RequestDispatcher;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class ShowUpdateUser extends AbstractAction
/*     */ {
/*  27 */   private static Logger logger = Logger.getLogger(ShowUpdateUser.class
/*  28 */     .getName());
/*     */ 
/*  30 */   private String id = "";
/*     */ 
/*     */   public ShowUpdateUser(AbstractHttpServlet servlet) {
/*  33 */     super(servlet);
/*     */   }
/*     */ 
/*     */   public ShowUpdateUser(AbstractHttpServlet servlet, String id) {
/*  37 */     super(servlet);
/*  38 */     this.id = id;
/*     */   }
/*     */ 
/*     */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException, ServletException, NotFoundException
/*     */   {
/*  44 */     User loginUser = super.getLoginUser(request);
/*     */ 
/*  47 */     if ((!loginUser.userId.equals(this.id)) && 
/*  48 */       (!loginUser.isAdmin) && (!loginUser.isGroupAdmin)) {
/*  49 */       response.sendRedirect(request.getContextPath() + 
/*  50 */         "/nopermission.jsp");
/*  51 */       return;
/*     */     }
/*     */ 
/*  55 */     if (("admin".equals(this.id)) && 
/*  56 */       (!"admin".equals(loginUser.userId))) {
/*  57 */       response.sendRedirect(request.getContextPath() + 
/*  58 */         "/nopermission.jsp");
/*  59 */       return;
/*     */     }
/*     */ 
/*  64 */     if ((!loginUser.userId.equals(this.id)) && (!loginUser.isAdmin)) {
/*  65 */       CompanyInfo company = super.getCompany(request);
/*  66 */       User updateUser = company.getUser(this.id);
/*  67 */       if (updateUser == null) {
/*  68 */         response.sendRedirect(request.getContextPath() + 
/*  69 */           "/nopermission.jsp");
/*  70 */         return;
/*     */       }
/*     */ 
/*  73 */       if (!company.isGroupAdmin(loginUser, updateUser.groupId)) {
/*  74 */         response.sendRedirect(request.getContextPath() + 
/*  75 */           "/nopermission.jsp");
/*  76 */         return;
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  81 */     UserManager userManager = new UserManager();
/*     */     try {
/*  83 */       User u = userManager.getUserBasicInfo(this.id);
/*  84 */       request.setAttribute("user", u);
/*     */     }
/*     */     catch (DBException e) {
/*  87 */       logger.warn("get user basic info failed", e);
/*  88 */       response.sendRedirect(request.getContextPath() + "/errorpage.jsp");
/*  89 */       return;
/*     */     }
/*     */ 
/*  93 */     UserEmailManager manager = new UserEmailManager();
/*     */     try {
/*  95 */       Map emailSettings = manager
/*  96 */         .getUserEmailSetting(this.id);
/*  97 */       request.setAttribute("emailSettings", emailSettings);
/*     */     } catch (DBException e) {
/*  99 */       logger.warn("get user email setting failed", e);
/*     */     } catch (SQLException e) {
/* 101 */       logger.warn("get user email setting failed", e);
/*     */     }
/*     */ 
/* 105 */     UserVOIPManager userVOIPManager = new UserVOIPManager();
/*     */     try {
/* 107 */       Map voip = userVOIPManager
/* 108 */         .getUserVOIPSetting(this.id);
/* 109 */       request.setAttribute("voip", voip);
/*     */     } catch (DBException e) {
/* 111 */       logger.warn("get user voip setting failed", e);
/*     */     } catch (SQLException e) {
/* 113 */       logger.warn("get user voip setting failed", e);
/*     */     }
/*     */ 
/* 116 */     CustomerFieldManager customerFieldManager = new CustomerFieldManager();
/*     */     try {
/* 118 */       List result = customerFieldManager
/* 119 */         .listAll(loginUser.companyId);
/* 120 */       request.setAttribute("customerfield", result);
/*     */     } catch (DBException e) {
/* 122 */       logger.warn("get user customer field failed", e);
/*     */     } catch (SQLException e) {
/* 124 */       logger.warn("get user customer field failed", e);
/*     */     }
/*     */ 
/* 127 */     request.getRequestDispatcher("/profiles.jsp")
/* 128 */       .forward(request, response);
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowUpdateUser
 * JD-Core Version:    0.6.1
 */